package blueBridge;

import java.util.Arrays;
import java.util.Scanner;
//思路：观察到数据较小,可以考虑DP解决问题。 定义dp[i][j]表示前i个数，分成j段的最大权值和，
//于是发现第i个数必然放在第j段中。于是有状态转移方程：
//dp[i][j] = max(dp[i - 1][j] , dp[i - 1][j - 1]) + a[i] * p[j]。
//最后输出dp[n][k]即可，这道题就愉快的出来了。
public class Main12112_Two {
  public static void main(String[] args) {
      Scanner scanner = new Scanner(System.in);
      int n = scanner.nextInt();
      int k = scanner.nextInt();

      long[] a = new long[n + 1];
      long[] p = new long[k + 1];
      for (int i = 1; i <= n; i++) {
          a[i] = scanner.nextLong();
      }
      for (int i = 1; i <= k; i++) {
          p[i] = scanner.nextLong();
      }

      long inf = 1L << 60;
      long[][] f = new long[n + 1][k + 1];
      for (int i = 0; i <= n; i++) {
          for (int j = 0; j <= k; j++) {
              f[i][j] = -inf;
          }
      }
      f[0][0] = 0;

      for (int i = 1; i <= n; i++) {
          for (int j = 1; j <= k; j++) {
              f[i][j] = Math.max(f[i - 1][j], f[i - 1][j - 1]) + a[i] * p[j];
          }
      }
      /*
      for (int i = 0; i <= n; i++) {
          System.out.println(Arrays.toString(f[i]));
      }*/

      System.out.println(f[n][k]);
  }
}
